﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using PrintScreens.Service.Printing;
namespace PrintScreens
{
    public partial class Printer : UserControl, IPrintWatcher
    {
        public Printer()
        {
            InitializeComponent();
            try
            {
                var PH = new PrintHelper(this);
                this.DataContext = PH;
            }
            catch
            {
            }
        }
        public void GotFirstPage(PrintingServiceFirstPage FP)
        {
            ((PrintHelper)DataContext).GotFirstPage(FP);
        }


        public void PrintStatusUpdate(string Status)
        {
            //Dispatcher.BeginInvoke(() => this.Status.Text = Status);
            this.Status.Text = Status;
        }


        public void Done()
        {
            //Dispatcher.BeginInvoke(()=>Progress.IsIndeterminate = false);
            Progress.IsIndeterminate = false;
            Progress.Value = Progress.Maximum;
        }

        private void BeginPrinting(object sender, RoutedEventArgs e)
        {
            ((Button)sender).Visibility = System.Windows.Visibility.Collapsed;
            Status.Text = "Printing...Please wait";
            ((PrintHelper)DataContext).BeginPrinting();
        }



        public void Ready()
        {
            //Dispatcher.BeginInvoke(()=>BP_Button.Visibility = Visibility.Visible);
            BP_Button.Visibility = Visibility.Visible;
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {

        }
    }
}
